<?php

class Cate extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->service('Service_urls');
        $this->load->driver('cache');
    }

    public function index($cate = 'index')
    {
        $params = $this->getParams();
        $page = !empty($params['page']) ? ((int)$params['page'] > 0 ? (int)$params['page'] : 1) : 1;

        $cond = ['status' => 0, 'show' => 1, 'title !=' => ''];
        if ($cate != 'index') {
            $cond['cate'] = $cate;
        }

        $list = $this->Service_urls->getList($page, $cond, 24);
        $pagination = $this->Service_urls->getPagination($page, $cond, 24);
        $pagination['url'] = $cate != 'index' ? '/cate/index/' . $cate : '/';
        $this->assign('tag', $this->cateMapping[$cate]);
        $this->assign('title', $cate != 'index' ? $this->cateMapping[$cate] : '');
        $this->assign('keywords', $this->site['keywords']);
        $this->assign('key', '');
        $this->assign('urls', $list);
        $this->assign('pagination', $pagination);
        $this->display("index.tpl");
    }
}